package com.ly.common.core.domain.entity;

import java.util.ArrayList;
import java.util.List;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ly.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
 * 菜单权限表 sys_menu
 *
 * @author ruoyi
 */
@EqualsAndHashCode ( callSuper = true )
@ApiModel ( value = "菜单", description = "菜单" )
@Data
@Accessors ( chain = true )
@TableName ( value = "sys_menu" )
public class SysMenu extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 菜单ID
     */
    @TableId ( value = "menu_id", type = IdType.INPUT )
    @ApiModelProperty ( value = "菜单ID" )
    private String menuId;

    /**
     * 菜单名称
     */
    @TableField ( value = "menu_name" )
    @ApiModelProperty ( value = "菜单名称" )
    private String menuName;

    /**
     * 父菜单名称
     */
    @TableField ( exist = false )
    @ApiModelProperty ( value = "菜单名称" )
    private String parentName;

    /**
     * 父菜单ID
     */
    @TableField ( value = "parent_id" )
    @ApiModelProperty ( value = "父菜单ID" )
    private String parentId;

    /**
     * 显示顺序
     */
    @TableField ( value = "order_num" )
    @ApiModelProperty ( value = "显示顺序" )
    private String orderNum;

    /**
     * 路由地址
     */
    @TableField ( value = "path" )
    @ApiModelProperty ( value = "路由地址" )
    private String path;

    /**
     * 组件路径
     */
    @TableField ( value = "component" )
    @ApiModelProperty ( value = "组件路径" )
    private String component;

    /**
     * 是否为外链（0是 1否）
     */
    @TableField ( value = "is_frame" )
    @ApiModelProperty ( value = "是否为外链（0是 1否）" )
    private String isFrame;

    /**
     * 是否缓存（0缓存 1不缓存）
     */
    @TableField ( value = "is_cache" )
    @ApiModelProperty ( value = "是否缓存（0缓存 1不缓存）" )
    private String isCache;

    /**
     * 类型（M目录 C菜单 F按钮）
     */
    @TableField ( value = "menu_type" )
    @ApiModelProperty ( value = "类型（M目录 C菜单 F按钮）" )
    private String menuType;

    /**
     * 显示状态（0显示 1隐藏）
     */
    @TableField ( value = "visible" )
    @ApiModelProperty ( value = "显示状态（0显示 1隐藏）" )
    private String visible;

    /**
     * 菜单状态（0显示 1隐藏）
     */
    @TableField ( value = "status" )
    @ApiModelProperty ( value = "菜单状态（0显示 1隐藏）" )
    private String status;

    /**
     * 权限字符串
     */
    @TableField ( value = "perms" )
    @ApiModelProperty ( value = "权限字符串" )
    private String perms;

    /**
     * 菜单图标
     */
    @TableField ( value = "icon" )
    @ApiModelProperty ( value = "权限字符串" )
    private String icon;

    /**
     * 是否关联模型
     */
    @TableField ( value = "related_model" )
    @ApiModelProperty ( value = "是否关联模型" )
    private Boolean relatedModel;

    @TableField ( value = "hide_route" )
    @ApiModelProperty ( value = "隐藏新增，修改页面路由" )
    private String hideRoute;

    @TableField ( value = "desc_info" )
    @ApiModelProperty ( value = "路由备注" )
    private String descInfo;

    @TableField ( value = "is_menu_btn" )
    @ApiModelProperty ( value = "是否为菜单按钮，增改查目前配置成菜单路由；前端渲染的时候需要排除这类按钮路由;true=按钮；false=目录或菜单" )
    private Boolean isMenuBtn;

    @TableField ( value = "level" )
    @ApiModelProperty ( value = "让所有二级菜单在页面上同一个模块显示，同一个模块的level相同，如果没有设置level的默认挂在第一个模块" )
    private Integer level;


    @TableField ( value = "hide_route_parent_menu" )
    @ApiModelProperty ( value = "隐藏新增，修改对应的父级menuId" )
    private String hideRouteParentMenu;

    @TableField ( exist = false )
    @ApiModelProperty ( value = "隐藏新增，修改对应的父级menuId" )
    private String hideRouteParentMenuName;

    public SysMenu ( SysMenu other ) {
        this.menuId = other.menuId;
        this.menuName = other.menuName;
        this.parentName = other.parentName;
        this.parentId = other.parentId;
        this.orderNum = other.orderNum;
        this.path = other.path;
        this.component = other.component;
        this.isFrame = other.isFrame;
        this.isCache = other.isCache;
        this.menuType = other.menuType;
        this.visible = other.visible;
        this.status = other.status;
        this.perms = other.perms;
        this.icon = other.icon;
        this.relatedModel = other.relatedModel;
        this.hideRoute = other.hideRoute;
        this.hideRouteParentMenu = other.hideRouteParentMenu;
        this.children = other.children;
        if ( other.children != null ) {
            this.children = new ArrayList<> ();
            for ( SysMenu child : other.children ) {
                this.children.add ( new SysMenu ( child ) ); // Recursive copy
            }
        }
    }

    public SysMenu () {
    }

    /**
     * 子菜单
     */
    @TableField ( exist = false )
    private List<SysMenu> children = new ArrayList<SysMenu> ();

    public String getMenuId () {
        return menuId;
    }

    public void setMenuId ( String menuId ) {
        this.menuId = menuId;
    }

    @NotBlank ( message = "菜单名称不能为空" )
    @Size ( min = 0, max = 50, message = "菜单名称长度不能超过50个字符" )
    public String getMenuName () {
        return menuName;
    }

    public void setMenuName ( String menuName ) {
        this.menuName = menuName;
    }

    public String getParentName () {
        return parentName;
    }

    public void setParentName ( String parentName ) {
        this.parentName = parentName;
    }

    public String getParentId () {
        return parentId;
    }

    public void setParentId ( String parentId ) {
        this.parentId = parentId;
    }

    @NotBlank ( message = "显示顺序不能为空" )
    public String getOrderNum () {
        return orderNum;
    }

    public void setOrderNum ( String orderNum ) {
        this.orderNum = orderNum;
    }

    @Size ( min = 0, max = 200, message = "路由地址不能超过200个字符" )
    public String getPath () {
        return path;
    }

    public void setPath ( String path ) {
        this.path = path;
    }

    @Size ( min = 0, max = 200, message = "组件路径不能超过255个字符" )
    public String getComponent () {
        return component;
    }

    public void setComponent ( String component ) {
        this.component = component;
    }

    public String getIsFrame () {
        return isFrame;
    }

    public void setIsFrame ( String isFrame ) {
        this.isFrame = isFrame;
    }

    public String getIsCache () {
        return isCache;
    }

    public void setIsCache ( String isCache ) {
        this.isCache = isCache;
    }

    @NotBlank ( message = "菜单类型不能为空" )
    public String getMenuType () {
        return menuType;
    }

    public void setMenuType ( String menuType ) {
        this.menuType = menuType;
    }

    public String getVisible () {
        return visible;
    }

    public void setVisible ( String visible ) {
        this.visible = visible;
    }

    public String getStatus () {
        return status;
    }

    public void setStatus ( String status ) {
        this.status = status;
    }

    @Size ( min = 0, max = 100, message = "权限标识长度不能超过100个字符" )
    public String getPerms () {
        return perms;
    }

    public void setPerms ( String perms ) {
        this.perms = perms;
    }

    public String getIcon () {
        return icon;
    }

    public void setIcon ( String icon ) {
        this.icon = icon;
    }

    public List<SysMenu> getChildren () {
        return children;
    }

    public void setChildren ( List<SysMenu> children ) {
        this.children = children;
    }

    public Boolean getRelatedModel () {
        return relatedModel;
    }

    public void setRelatedModel ( Boolean relatedModel ) {
        this.relatedModel = relatedModel;
    }
}
